/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication5.model;

import java.util.ArrayList;
import javax.swing.JTextField;

/**
 *
 * @author mathieubakrim
 */
public class AddressBookModel {
    private ArrayList<Contact> contactsList = new ArrayList<Contact>();
    private String [] group = {"Friends", "family", "companies", "co-workers"};
    
    public AddressBookModel(){
        createContact("test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "Test9");
    }

    public String[] getGroup() {
        return group;
    }
    
    
    
    /**
     * Getter
     * @return List of contacts actually saved in memory
     **/
    public ArrayList<Contact> getContactsList() {
        return contactsList;
    }
    
    
/**
     * Create a contact with datas read from the controller
     * @param in: array of the Createform's textfields
     * @param out: an Object Contact, saved in model arraylist
     **/
     public Contact createContact(String ln, String fn, String pn, String ap, String ape, String hp, String ep, String epe, String gr) {
            
         Contact c = new SimpleContact(ln, fn, pn, ap, ape, hp, ep, epe, gr);
       
         contactsList.add(c);
         System.out.println("List: " + getContactsList().toString());
         return c;
     }  
    /**
     * Delete a contact
     * @Todo : destroy the object after removing it from the list
     **/
    public void deleteContact(Contact c){
        contactsList.remove(c);
    }
    
}


